System and method for automatic focusing of images

ABSTRACT

A method for automatic focusing of images is disclosed. The method includes steps: sending an instruction to a motor ( 17 ) which is installed on a Z axis of a measure machine ( 19 ); setting particular parameters required for focusing images, and set a start location and an end location for the Z axis; controlling the Z axis to move within a predetermined focusing area; retrieving consecutive images; pretreating the consecutive images; calculating definition values of the consecutive images; determining whether the Z axis has arrived at the end location; determining whether it is the second time to focus the images, if the Z axis has arrived at the end location; calculating a focus location of the consecutive images, if it is the second time to focus the images; and outputting the calculated focus location. A system for automatic focusing of images is also disclosed.

FIELD OF THE INVENTION

The present invention generally relates to systems and methods for image measuring, and more particularly to a system and method for focusing of images.

DESCRIPTION OF RELATED ART

A Charged Coupled Device (CCD) is an electrical device that is used to create images of objects, store information (analogous to the way a computer stores information), or transfer electrical charge (as part of larger device). It receives as input light from an object or an electrical charge. The CCD takes this optical or electronic input and converts it into an electronic signal—the output. The electronic signal is then processed by some other equipment and/or software to either produce an image or to give the user valuable information.

CCDs are used in a variety of different imaging devices, such as imagers or CCD cameras or scanners, in which, CCDs are only part of the whole device. For gathering images of objects, a lens is required to properly focus the incident radiation from the object onto the array.

China Pat. No. 2,321,022Y, entitled “auto-focusing apparatus” and issued on May 26, 1999 discloses an auto-focusing apparatus set on a scanner. The apparatus includes: a lens position adjusting unit which can adjust positions of a lens, a CCD position adjusting unit which can adjust positions of the CCD, and a controlling unit which can control the lens position adjusting unit and the CCD position adjusting unit. When turned on, the scanner can adjust the lens and the CCD to a suitable location according to the lens' required optical path and foci when imaging, so as to make objects focused and imaged on the CCD.

However, the above-mentioned invention is only to adjust hardware apparatuses in order to actualize focusing, so it is difficult to ensure focusing precision.

Therefore, what is needed is a system and method for automatic focusing of images, which can ensure focusing precision.

SUMMARY OF INVENTION

One embodiment of the present invention provides a system for automatic focusing of images as described herein. The system includes a measure machine and a computer. The measure machine has a Z axis, which is installed with a Charged Coupled Device (CCD) and a motor. The computer is connected with the CCD by an image acquisition card and connected with the motor by a controlling card.

The computer includes an inputting/outputting module, a parameter setting module, a calculating module, a data storing module, a determining module, and a processing module.

The inputting/outputting module is used for retrieving consecutive images of objects on the measure machine from the CCD, outputting instructions to the motor for controlling the Z axis to move within a predetermined focusing area, and outputting a focus location of the consecutive images. The parameter setting module is used for setting particular parameters required for focusing images, and setting a start location and an end location for the Z axis of the measure machine according to an approximate focus location and the predetermined focusing area. The calculating module is used for calculating definition values of the consecutive images and obtaining a corresponding focus location according to the definition values. The determining module is used for determining whether the Z axis has arrived at the end location, and determining whether it is the second time to focus the images when the Z axis has arrived at the end location.

Another embodiment of the present invention provides a method for automatic focusing of images. The method includes the steps of: (a) sending an instruction from a computer to a motor which is installed on a Z axis of a measure machine; (b) setting particular parameters required for focusing images, and set a start location and an end location for the Z axis of the measure machine; (c) controlling the Z axis of the measure machine to move within a predetermined focusing area from the start location; (d) retrieving consecutive images of objects on the measure machine acquired by a Charged Coupled Device (CCD) which is installed on the Z axis of the measure machine; (e) pretreating the consecutive images; (f) calculating definition values of the consecutive images; (g) determining whether the Z axis of the measure machine has arrived at the end location; (g) determining whether it is the second time to focus the images, if the Z axis of the measure machine has arrived at the end location; (h) calculating a focus location of the consecutive images according to the calculated definition values, if it is the second time to focus the images; and (i) outputting the calculated focus location.

Other objects, advantages and novel features of the embodiments will be drawn from the following detailed description together with the attached drawings, in which:

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic diagram of hardware configuration and an application environment of a system for automatic focusing of images in accordance with a preferred embodiment of the present invention;

FIG. 2 is a schematic diagram of main function modules of a client computer of the system of FIG. 1; and

FIG. 3 is a flow chart of a preferred method for automatic focusing of images by utilizing the system of FIG. 1.

DETAILED DESCRIPTION

FIG. 1 is a schematic diagram of hardware configuration and an application environment of a system for automatic focusing of images (hereinafter, “the system”), in accordance with a preferred embodiment of the present invention. The system includes a client computer 11 and a measure machine 19 for objects to be laid thereon for measurement. A Charged Coupled Device 16 (hereinafter, “CCD 16”) is installed on a Z axis of the measure machine 19. The CCD 16 is used for acquiring consecutive images of the objects on the measure machine 19 by using an optical lens 18 which is installed in front of the CCD 16. The client computer 11 includes an image acquisition card 12, a controlling card 13, and a data storage 20. The CCD 16 is connected with the image acquisition card 12 via an image signal bus 14, through which the CCD 16 can transmit electrical signals of the consecutive images acquired from the measure machine 19 to the image acquisition card 12. The controlling card 13 is connected with a Z axis motor 17 installed on the Z axis of the measure machine 19 via a control signal bus 15, through which the controlling card 13 can send instructions to the Z axis motor 17 for controlling the Z axis of the measure machine 19 to move within a predetermined focusing area. The data storage 20 is used for storing definition values of the consecutive images and respective locations of the Z axis of the measure machine 19.

FIG. 2 is a schematic diagram of main function modules of the client computer 11. The client computer 11 includes an inputting/outputting module 111, a parameter setting module 112, a calculating module 113, a data storing module 114, a determining module 115, and a processing module 116. The inputting/outputting module 111 is used for retrieving the consecutive images of the objects on the measure machine 19 from the CCD 16 by using the image acquisition card 12. The consecutive images are gathered by the optical lens 18 and acquired by the CCD 16. The inputting/outputting module 111 is also used for outputting instructions to the Z axis motor 17 by using the controlling card 13, for the Z axis motor 17 to drive the Z axis of measure machine 19 to move within a predetermined focusing area, and outputting a focus location of the consecutive images on a graphic user interface of the client computer 11. The parameter setting module 112 is used for setting particular parameters required for focusing images, and setting a start location and an end location for the Z axis of the measure machine 19 according to an approximate focus location and the predetermined focusing area. The particular parameters include a parameter regarding whether to filtrate the consecutive images, and a parameter regarding an image calculating region. The calculating module 113 is used for calculating definition values of the consecutive images and obtaining a corresponding focus location according to the definition values. The data storing module 114 is used for storing the calculated definition values of the consecutive images and respective locations of the Z axis of the measure machine 19 temporarily in the data storage 20. The determining module 115 is used for determining whether the Z axis of the measure machine 19 has arrived at the end location. If the Z axis has not arrived at the end location, the Z axis motor 17 controls the Z axis to keep on moving towards the end location. The determining module 115 further determines whether it is the second time to focus the images when the Z axis has arrived at the end location. The processing module 116 is used for analyzing and pretreating the consecutive images. The pretreatment may include clearing data temporarily stored in the data storage 20 and filtrating the consecutive images.

FIG. 3 is a flow chart of a preferred method for automatic focusing of images by utilizing the system of FIG. 1. In step S300, the client computer 11 sends a focusing instruction to the controlling card 13. In step S302, the parameter setting module 112 sets particular parameters required for focusing images, and sets a start location and an end location for the Z axis of the measure machine 19. The particular parameters typically include a parameter regarding whether to filtrate consecutive images obtained by the CCD 16 while the Z axis of the measure machine 19 is moving, and a parameter regarding an image calculating region. The start location and the end location of the Z axis of the measure machine 19 are calculated according to an approximate focus location and a predetermined focusing area. The approximate focus location is generally determined by a user according to his/her experience. In step S304, the controlling card 13 transmits a controlling instruction to the Z axis motor 17, for the Z axis motor 17 to control the Z axis of the measure machine 19 to move within the predetermined focusing area from the start location. Meanwhile, the CCD 16 acquires consecutive images of the objects on the measure machine 19 by using the optical lens 18, and the inputting/outputting module 111 retrieves electrical signals of the consecutive images from the CCD 16 via the image acquisition card 12. In step S306, the processing module 116 pretreats the consecutive images. The pretreatment may include clearing data temporarily stored in the data storing module 114 and filtrating the consecutive images. In step S308, the calculating module 113 calculates definition values of the consecutive images according to pixel values of the consecutive images. The pixel values are evaluated by using a gradient method. It should be noted that the better gradient of two adjacent pixels, the better images sharpening and fine distinction between white and black area. The calculating transform is using the function for evaluating of the sum of the absolute value of the difference between pixel values in four-square matrix pixels as below: ${P\quad 1} = {\sum\limits_{X = 1}^{N - 2}{\sum\limits_{Y = 1}^{N - 2}\begin{bmatrix} {{{{f\quad\left( {x\text{,}y} \right)} - {f\quad\left( {x - {1\text{,}y}} \right)}}} +} \\ {{{{f\quad\left( {x\text{,}y} \right)} - {f\quad\left( {{x\text{,}y} - 1} \right)}}} +} \\ {{{{f\quad\left( {x\text{,}y} \right)} - {f\quad\left( {x + {1\text{,}y}} \right)}}} +} \\ {{{f\quad\left( {x\text{,}y} \right)} - {f\quad\left( {{x\text{,}y} + 1} \right)}}} \end{bmatrix}}}$ In the above-described function, P1 is a sum of an absolute value of the difference between pixel values in four-square matrix pixel. N is the total number of pixels of an image, and x and y are coordinates in a reference system. The data storing module 114 stores the calculated definition values and respective locations of the Z axis of the measure machine 19 temporarily in the data storage 20. In step S310, the determining module 115 determines whether the Z axis of the measure machine 19 has arrived at the end location. If the Z axis has not arrived at the end location, the Z axis motor 17 controls the Z axis to keep on moving towards the end location. The procedure returns to step 304 described above, and the CCD 16 acquires new consecutive images of the objects accordingly. If the Z axis has arrived at the end location, that means the process of focusing images has been completed once, then in step 312, the determining module 115 determines whether it is the second time to focus the images. If it is not the second time to focus the images, a new start location and a new end location are set according to the largest definition value of all the calculated definition values and the predetermined focusing area. Then, the Z axis of the measure machine 19 moves to the new start location, and the procedure returns to step 304 described above. If it is the second time to focus the images, in step 314, the calculating module 113 calculates a focus location of the consecutive images according to the calculated definition values. Generally, the location of the Z axis corresponding to the largest definition value is the focus location. Then, the Z axis of the measure machine 19 moves to the focus location. In step 316, the inputting/outputting module 111 outputs the calculated focus location.

It should be emphasized that the above-described embodiments of the present invention, particularly, any “preferred” embodiments, are merely possible examples of implementations, merely set forth for a clear understanding of the principles of the invention. Many variations and modifications may be made to the above-described embodiment(s) of the invention without departing substantially from the spirit and principles of the invention. All such modifications and variations are intended to be included herein within the scope of this disclosure and the present invention and protected by the following claims. 

1. A system for automatic focusing of images comprising a measure machine and a computer, the measure machine having a Z axis, the Z axis being installed with a Charged Coupled Device (CCD) and a motor, the computer being connected with the CCD by an image acquisition card and connected with the motor by a controlling card, the computer comprising: an inputting/outputting module for retrieving consecutive images of objects on the measure machine from the CCD, outputting instructions to the motor for controlling the Z axis to move within a predetermined focusing area, and outputting a focus location of the consecutive images; a parameter setting module for setting particular parameters required for focusing images, and setting a start location and an end location for the Z axis of the measure machine according to an approximate focus location and the predetermined focusing area; a calculating module for calculating definition values of the consecutive images and obtaining a corresponding focus location according to the definition values; and a determining module for determining whether the Z axis has arrived at the end location, and determining whether it is the second time to focus the images when the Z axis has arrived at the end location.
 2. The system according to claim 1, wherein the computer further comprises a processing module for analyzing and pretreating the consecutive images.
 3. The system according to claim 1, wherein the computer further comprises a data storing module for storing the calculated definition values of the consecutive images and respective locations of the Z axis of the measure machine temporarily in a data storage.
 4. The system according to claim 1, wherein the calculating module calculates definition values of the consecutive images according to image pixel values evaluated by applying a gradient method, and the calculating transform is using the function for evaluating the sum of the absolute value of the difference between pixel values in four-square matrix pixels.
 5. A computer-based method for automatic focusing of images, the method comprising the steps of: sending an instruction from a computer to a motor which is installed on a Z axis of a measure machine; setting particular parameters required for focusing images, and set a start location and an end location for the Z axis of the measure machine; controlling the Z axis of the measure machine to move within a predetermined focusing area from the start location; retrieving consecutive images of objects on the measure machine acquired by a Charged Coupled Device (CCD) which is installed on the Z axis of the measure machine; pretreating the consecutive images; calculating definition values of the consecutive images; determining whether the Z axis of the measure machine has arrived at the end location; determining whether it is the second time to focus the images, if the Z axis of the measure machine has arrived at the end location; calculating a focus location of the consecutive images according to the calculated definition values if it is the second time to focus the images; and outputting the calculated focus location.
 6. The method according to claim 5, wherein the particular parameters comprises: a parameter regarding whether to filtrate the consecutive images; a parameter regarding an image calculating region.
 7. The method according to claim 5, wherein the step of pretreating the consecutive images comprises: clearing data temporarily stored in a data storage; filtrating the consecutive images.
 8. The method according to claim 5, further comprising: controlling the Z axis to keep on moving towards the end location, if the Z axis has not arrived at the end location; and returning to the retrieving step.
 9. The method according to claim 5, further comprising: setting a new start location and a new end location according to the largest definition value of all the calculated definition values, if it is not the second time to focus images; and returning to the retrieving step. 